package nio.bytebuffer;

import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;

/**
 * WritesDemo
 *
 * @author chenxin
 * @date 2022/05/14 18:30
 **/
public class WritesDemo {

    public static void main(String[] args) throws Exception {

        ByteBuffer buffer = StandardCharsets.UTF_8.encode("hell11223123o");
        ByteBuffer buffer2 = StandardCharsets.UTF_8.encode("worl3333d");
        ByteBuffer buffer3 = StandardCharsets.UTF_8.encode("你好11231");

        FileChannel channel = new RandomAccessFile("src/main/resources/data4.txt", "rw").getChannel();
        channel.write(new ByteBuffer[]{buffer, buffer2, buffer3});

    }

}